/*
 * Copyright (c) 2019-2020, https://api.iot.10086.cn/(https://gitee.com/cmcc-iot-api/iot-card-open-application/).
 */
package cn.iot.card.open.tariff.controller;

import cn.iot.card.open.annotion.Permission;
import cn.iot.card.open.tariff.service.TariffChargesService;
import cn.iot.card.open.util.CommonUtil;
import cn.stylefeng.roses.core.base.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;

/**
 * 资费信息控制器
 *
 * @author 何光鑫
 * @date 20200221 10:33:22
 * @modify 20200221 何光鑫 v1.1.1 创建
 * @since v1.1.1
 */
@Controller
@RequestMapping("/charges")
public class TariffChargesController extends BaseController {

    /**
     * 资费信息页面路径地址前缀
     */
    private static String PREFIX = "/modular/tariff/charges/";

    @Autowired
    private TariffChargesService tariffChargesService;

    /**
     * 跳转到资费信息查询列表页面
     *
     * @return 返回 string
     * @author 何光鑫
     * @date 20200108 09:00:04
     * @modify 20200108 何光鑫 v1.1.1 创建
     * @since v1.1.1
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "charges.html";
    }

    /**
     * 查询资费信息列表
     */
    @RequestMapping("/list")
    @Permission
    @ResponseBody
    public Object list(@RequestParam(required = false) String accountId, @RequestParam(required = false) String offeringId) throws IOException{
        String transId = CommonUtil.generateTransId(String.valueOf(accountId));
        return tariffChargesService.queryOfferingsDetail(transId,accountId,offeringId);
    }
}
